<% title "Cources", false %>

<div id="page-header">
  
  <div class="page-help-section">
    
  </div>
  <div class="page-help-navigator">
    <span id="help-button">Help</span>
  </div>
  
  <span class="page-icons page_course_icon"></span>
  <h1 class="page-name">Courses</h1>
</div>

<br/>

<div class="page-form">
  <!-- GRID HEADER --> 
  <div class="grid-top-bar">
    <div class="grid-box">
      <select id="batch_action">
        <option selected="true">Bulk Actions</option>
        <option value="delete">Move to Trash</option>
      </select>
      <input type="submit" value="Apply" class="button">
    </div>
    <div class="grid-box">
      <label><input type="checkbox" id="course_filter_publish" value="published" onchange="filter_published_course()"/> Published only</label>
    </div>
    <div class="grid-box float-right">
      <label class="align-right"><i><%= Course.all.count %> Courses</i></label>
    </div>
  </div>
  <!-- GRID HEADER ENDS -->
  <table class="grid" cellspacing="0" cellpadding="0">
    <thead class="grid_header">
      <tr>
        <th class="grid_chkbox">
          <input type="checkbox"/>
        </th>
        <th class="grid_title">Title</th>
        <th class="grid_meta">State</th>
        <th class="grid_dates">Dates</th>
      </tr>
    </thead>
    <% @courses.each do |course| %>
      <%= render :partial => "courserow", :object => course, :locals => {:level => 0}  %>
    <% end %>
    <tfoot class="grid_header">
      <tr>
        <th class="grid_chkbox">
          <input type="checkbox"/>
        </th>
        <th class="grid_title">Title</th>
        <th class="grid_meta">State</th>
        <th class="grid_dates">Dates</th>
      </tr>
    </tfoot>
  </table>
</div>

<script type="text/javascript">
  function filter_published_course(){
    //alert($("input#course_filter_publish").is(':checked'));
    if($("input#course_filter_publish").is(':checked')) {
      $("tr.published_false").css('display', 'none');
    } else {
      $("tr.published_false").css('display', 'table-row');
    }
  }
</script>